<?php use_helper('I18N'); ?>
<style type="text/css">
    p img {
        background: none repeat scroll 0 0 white;
        border: 1px solid #BBBBBB;
        margin: 7px 14px 7px 0;
        padding: 5px;
        height: 50px;
        /*width: 160px;*/
    }
</style>
<script type="text/javascript">
    $(function() {
        $("#btnBack").button({
            icons: {
                primary: "ui-icon-circle-arrow-w"
            }
        });
    });
</script>
<div id="content">

<!-- ========== CATEGORIES TABS ========= -->
<!-- ==================================== -->
<table id="contentMainWrapper" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td id="column-left" style="width: 215px;">
    <div style="width:215px;">
        <!--// bof: categories //-->
        <div class="box" id="categories" style="width:215px;">
            <div class="box-border">
                <div class="box-head">
                    <?php echo __('Categories') ?>
                </div>
                <div class="box-body">
                    <?php include_component('component', 'categoriesSideMenu') ?>
                </div>
            </div>
        </div>
        <!--// eof: categories //-->
        <!--// bof: specials //-->
        <div class="box" id="specials" style="width:215px;">
            <div class="box-border">
                <div class="box-head">
                    <a href="<?php echo url_for("/product/specialItem") ?>"><?php echo __('Specials') ?></a>
                </div>
                <div class="box-body">
                    <?php include_component('component', 'specialsSideMenu', array('param' => 'will implement for categoryType')) ?>
                </div>

            </div>
        </div>
        <!--// eof: specials //-->
    </div>
</td>
<td id="column-center" valign="top">
    <div class="column-center-padding">
        <div class="centerColumn" id="checkoutConfirmDefault">

            <form name="checkoutForm" action="/checkout/checkout" method="post">
                <?php
                $timeStamp = strtotime($cmsMemberOrder->getCreatedOn());
                $dateString = date(Globals::FULL_DATETIME_FORMAT, $timeStamp);
                ?>
                <div class="forward">Order Date: <?php echo $dateString; ?></div>

                <br class="clearBoth">

                <table id="cartContentsDisplay" border="0" cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #E1E1E1">
                     <caption><h2 id="orderHistoryStatus">Order Information - Order #<?php echo $cmsMemberOrder->getOrderId()?></h2></caption>
                    <tbody>
                    <tr class="cartTableHeading">
                        <th scope="col" id="ccQuantityHeading" width="30"><?php echo __('Qty') ?></th>
                        <th scope="col" id="ccProductsHeading"><?php echo __('Item Name') ?></th>
                        <th scope="col" id="ccUnitHeading"><?php echo __('Unit') ?></th>
                        <th scope="col" id="ccTotalHeading"><?php echo __('Total') ?></th>
                    </tr>
                <?php
                    $totalAmountInCart = 0;
                    foreach ($cmsMemberOrderDetails as $cmsProduct):
                        $title = $cmsProduct->getProductName() . " #" . $cmsProduct->getProductCode();
                        if ($sf_user->getCulture() == "cn") {
                            $title = $cmsProduct->getProductNameCn() . " #" . $cmsProduct->getProductCode();
                        }
                        ?>
                    <tr class="rowEven">
                        <td class="cartQuantity"><?php echo $cmsProduct->getQty();?>&nbsp;x</td>
                        <td class="cartProductDisplay"><?php echo $title; ?></td>
                        <td class="cartProductDisplay">RM <?php echo number_format($cmsProduct->getPrice(), 2);?></td>

                        <td class="accountTotalDisplay">
                            RM <?php echo number_format($cmsProduct->getQty() * $cmsProduct->getPrice(), 2); $totalAmountInCart += ($cmsProduct->getQty() * $cmsProduct->getPrice());?>
                        </td>
                    </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <hr>

                <div id="orderTotals">
                        <div class="amount larger forward">RM <?php echo number_format($totalAmountInCart, 2);?></div>
                        <div class="lineTitle larger forward">Sub-Total:</div>
                    <br class="clearBoth">

                        <div class="amount larger forward">
                            RM <?php echo number_format($cmsMemberOrder->getDeliveryAmount(), 2);?></div>
                        <div class="lineTitle larger forward">Delivery Charge
                            (<?php echo $cmsMemberOrder->getDeliveryName() ?>):
                        </div>
                    <br class="clearBoth">

                        <div class="amount larger forward">
                            RM <?php echo number_format($totalAmountInCart + $cmsMemberOrder->getDeliveryAmount(), 2);?></div>
                        <div class="amount larger forward">Total:</div>
                    <br class="clearBoth">
                </div>

                <table width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 1px solid #E1E1E1"
                       summary="Table contains the date, order status and any comments regarding the order"
                       id="cartContentsDisplay">
                    <caption><h2 id="orderHistoryStatus">Status History &amp; Comments</h2></caption>
                    <tbody>
                    <tr class="tableHeading">
                        <th id="myAccountStatusDate" scope="col">Date</th>
                        <th id="myAccountStatus" scope="col">Order Status</th>
                        <th id="myAccountStatusComments" scope="col">Comments</th>
                    </tr>
                    <?php foreach ($cmsMemberOrderStatuses as $cmsMemberOrderStatus): ?>
                    <tr>
                        <td><?php
                            $timeStamp = strtotime($cmsMemberOrderStatus->getCreatedOn());
                            $dateString = date(Globals::FULL_DATETIME_FORMAT, $timeStamp);

                            echo $dateString;?></td>
                        <td><?php echo $cmsMemberOrderStatus->getStatusCode(); ?></td>
                        <td><?php echo $cmsMemberOrderStatus->getRemarks(); ?></td>
                    </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
                <hr>

                <div id="checkoutShipto" class="backward">
                    <h2 id="checkoutConfirmDefaultShippingAddress">Delivery/Shipping Information</h2>

                    <address>
                        <?php $address = $cmsMemberOrder->getAddress1();

                        if ($cmsMemberOrder->getAddress2() != null && $cmsMemberOrder->getAddress2() != "")
                            $address .= "<br>" . $cmsMemberOrder->getAddress2();

                        $address2 = "";
                        if ($cmsMemberOrder->getPostcode() != null && $cmsMemberOrder->getPostcode() != "")
                            $address2 = $cmsMemberOrder->getPostcode();

                        if ($cmsMemberOrder->getCity() != null && $cmsMemberOrder->getCity() != "") {
                            if ($address2 != "")
                                $address2 .= " ";
                            $address2 .= $cmsMemberOrder->getCity();
                        }
                        if ($cmsMemberOrder->getState() != null && $cmsMemberOrder->getState() != "") {
                            if ($address2 != "")
                                $address2 .= "<br>";
                            $address2 .= $cmsMemberOrder->getState();
                        }
                        if ($cmsMemberOrder->getCountry() != null && $cmsMemberOrder->getCountry() != "") {
                            if ($address2 != "")
                                $address2 .= " ";
                            $address2 .= $cmsMemberOrder->getCountry();
                        }

                        echo $address . "<br>" . $address2;
                        ?>
                    </address>

                    <hr>
                    <h3 id="checkoutConfirmDefaultShipment">Shipping Method:</h3>
                    <h4 id="checkoutConfirmDefaultShipmentTitle"><?php echo $cmsMemberOrder->getDeliveryName() ?></h4>
                    <hr>
                    <h3>Payment Method:</h3>
                    <h4><?php
                        if ("banktransfer" == $cmsMemberOrder->getPaymentMethod())
                            echo "Bank Transfer";
                        else
                            echo $cmsMemberOrder->getPaymentMethod();
                        ?></h4>

                </div>
                <br class="clearBoth">
                <hr>

                <h2 id="shpping">Special Instructions or Order Comments (Shipping)</h2>

                <div>
                <?php
                    if ($cmsMemberOrder->getDeliveryComment() == "")
                    echo "None";
                else
                    echo $cmsMemberOrder->getDeliveryComment();
                    ?>
                </div>
                <br class="clearBoth">
                <hr>

                <h2 id="checkoutConfirmDefaultHeadingComments">Special Instructions or Order Comments (Payment)</h2>

                <div>
                <?php
                    if ($cmsMemberOrder->getPaymentComment() == "")
                    echo "None";
                else
                    echo $cmsMemberOrder->getPaymentComment();
                    ?>
                </div>
                <br class="clearBoth">
                <hr>

                <br class="clearBoth">

                <div class="buttonRow back">
                    <a id="btnBack" href="<?php echo url_for("/member/myAccount");?>"><?php echo __('Back') ?></a>
                </div>
            </form>
        </div>

        <div class="clear"></div>
    </div>
</td>
</tr>
</tbody>
</table>

</div>